package com.tanhua.server.controller;

import com.tanhua.commons.utils.JwtUtils;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.server.service.UserService;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author lifeihu
 * @date 2021/12/22
 * @TIME:18:07
 */
@RestController
@RequestMapping("/user")
public class LoginController {
    @Autowired
    private UserService userService;
    @PostMapping("login")
    public ResponseEntity login(@RequestBody Map<String, String> param) {
        //1. 获取手机号
        String phone = param.get("phone");
        //2. 发送验证码
        userService.sendCode(phone);
        //3. 返回数据
        return ResponseEntity.ok(null);
    }
    @PostMapping("/loginVerification")
    public ResponseEntity loginVerification(@RequestBody Map map){
        String phone = (String) map.get("phone");
        String verificationCode = (String) map.get("verificationCode");
         Map retMap = userService.loginVerification(phone, verificationCode);
        return ResponseEntity.ok(retMap);
    }
}
